/*
===========================================================================
This source file is part of DyLab (Dynamic Laboratory)
For the latest info, see http://dylab-modules.googlecode.com

Copyright (c) 2006-2008 Lukas Krejci
(krejci.lukas@volny.cz)

This file is part of DyLab.

    DyLab is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    DyLab is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with DyLab.  If not, see <http://www.gnu.org/licenses/>.
===========================================================================
*/

//===========================================================================================
#include "Ogre_Gfx.h"

//===========================================================================================
dylab::Ogre_Gfx::Light::Light(const String & _name, IScene * _scene, type_t _type)
: mType(_type)
{
    mOgreLight = dynamicCast<Scene>(_scene)->getOgreSceneMgr()->createLight(_name);
    DYLAB_ASSERT(mOgreLight != NULL);

    switch (mType)
    {
    case DIRECTIONAL:
        mOgreLight->setType(Ogre::Light::LT_DIRECTIONAL);
        break;
    case POINT:
        mOgreLight->setType(Ogre::Light::LT_POINT);
        break;
    case SPOTLIGHT:
        mOgreLight->setType(Ogre::Light::LT_SPOTLIGHT);
        break;
    }
}
//-----------------------------------------------------------------------------
dylab::Ogre_Gfx::Light::~Light()
{
}
//-----------------------------------------------------------------------------
dylab::String dylab::Ogre_Gfx::Light::getName() const
{
    return mOgreLight->getName();
}
//-----------------------------------------------------------------------------
dylab::Ogre_Gfx::Light::type_t dylab::Ogre_Gfx::Light::getType() const
{
    return mType;
}
//-----------------------------------------------------------------------------
void dylab::Ogre_Gfx::Light::setPosition(const Vector3 & _position)
{
    mOgreLight->setPosition(toOgreVector3(_position));
}
//-----------------------------------------------------------------------------
dylab::Vector3 dylab::Ogre_Gfx::Light::getPosition() const
{
    return toVector3(mOgreLight->getPosition());
}
//-----------------------------------------------------------------------------
void dylab::Ogre_Gfx::Light::setDirection(const Vector3 & _position)
{
    mOgreLight->setDirection(toOgreVector3(_position));
}
//-----------------------------------------------------------------------------
dylab::Vector3 dylab::Ogre_Gfx::Light::getDirection() const
{
    return toVector3(mOgreLight->getDirection());
}
//-----------------------------------------------------------------------------
void dylab::Ogre_Gfx::Light::setDiffuseColour(const Colour & _colour)
{
    mOgreLight->setDiffuseColour(toOgreColour(_colour));
}
//-----------------------------------------------------------------------------
dylab::Colour dylab::Ogre_Gfx::Light::getDiffuseColour() const
{
    return toColour(mOgreLight->getDiffuseColour());
}
//-----------------------------------------------------------------------------
void dylab::Ogre_Gfx::Light::setSpecularColour(const Colour & _colour)
{
    mOgreLight->setSpecularColour(toOgreColour(_colour));
}
//-----------------------------------------------------------------------------
dylab::Colour dylab::Ogre_Gfx::Light::getSpecularColour() const
{
    return toColour(mOgreLight->getSpecularColour());
}
//-----------------------------------------------------------------------------
void dylab::Ogre_Gfx::Light::setAttenuation(real_t _range, real_t _constant, real_t _linear, real_t _quadratic)
{
    mOgreLight->setAttenuation(_range, _constant, _linear, _quadratic);
}
//-----------------------------------------------------------------------------
void dylab::Ogre_Gfx::Light::setCastShadows(bool _castShadows)
{
    mOgreLight->setCastShadows(_castShadows);
}
//-----------------------------------------------------------------------------